home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / asmutil / asm_n_z.zip / SPRITES3.ASM < prev    next >
Assembly Source File  |  1986-05-27  |  3KB  |  106 lines

  1. ;
  2. ; *** Listing 3 ***
  3. ;
  4. ;Byte-move graphics driver for putting rectangular images into
  5. ; the Color/Graphics Adapter's medium-resolution memory map.
  6. ;
  7. ; Inputs (DS and CS must be the same, ES must contain 0B800h):
  8. ;
  9. ;   BX - Row at which to put the top of the image. Range is 0 to 198.
  10. ;      BX must be even: images cannot start at an odd row.
  11. ;
  12. ;   CX - The column at which to start the image in bytes. Range is
  13. ;      0 to 79.
  14. ;
  15. ;   SI - Points to data structure which contains the image description.
  16. ;      The first byte is the height in lines (h). The second is the
  17. ;      width of the image in bytes (w). h*w image bytes follow which
  18. ;      contain the values to be placed into the screen memory map.
  19. ;      The image bytes are ordered as h consecutive sets of w line
  20. ;      image bytes.    h must be an even number; images must be an
  21. ;      even number of scan lines high.
  22. ;
  23. ; Outputs:
  24. ;
  25. ;   None.
  26. ;
  27. ; Note: AX,BX,CX,DX,BP,SI,DI destroyed.
  28. ;
  29. cseg    segment para public 'cseg'
  30.     assume    cs:cseg,ds:cseg,es:nothing
  31.     public    byte_move_form_driver
  32. ;
  33. byte_move_form_driver proc near
  34.     mov    di,[bx+even_line_screen_offset_table]  ;find the offset
  35.                                ; of the top
  36.                                ; line of image
  37.     add    di,cx     ;ES:DI now points to byte at which to put
  38.              ; the image's upper left corner
  39.     lodsb         ;get the height of the image
  40.     xor    ah,ah     ;make height a word value for calculations
  41.     mov    bx,ax     ;store height in BX
  42.     lodsb         ;get the width of the image in bytes
  43.     mov    bp,2000h ;calculate the amount to add after even scan
  44.     sub    bp,ax     ; lines are drawn to get to the address of the
  45.              ; next scan line
  46.     mov    dx,1fb0h ;calculate the amount to subtract after odd 
  47.     add    dx,ax     ; scan lines are drawn to get to the address
  48.              ; of the next scan line
  49.     jmp    [bx+inline_height_vector_table-2] ;-2 because there is
  50.                           ; no zero lines entry
  51.                           ; point
  52. ;
  53. ;This table is used to find the offset of an even scan line in
  54. ; the memory map of the color graphics adapter in medium 
  55. ; resolution mode.
  56. ;
  57. even_line_screen_offset_table label word
  58. x=0
  59.     rept    100    ;there are 100 even lines
  60.     dw    x*50h    ; each is 50h (80 decimal) long
  61. x=x+1
  62.     endm
  63. ;
  64. ;This is inline code for moving the image into the screen memory map.
  65. ;
  66. label    macro    x    ;this macro is used to label the inline code
  67. line&x&:        ; entry points
  68.     endm
  69. ;
  70. x=42            ;there will be an entry point for each even
  71.             ; number of lines between 2 and 40. They will
  72.             ; be labeled "line2", "line4", ... "line40"
  73.     rept    20
  74. x=x-2            ;calculate number of lines for this entry point
  75.     label    %x    ;put in label for entry point
  76.     mov    cx,ax    ;put width of image in bytes in CX to prepare
  77.     rep    movsb    ; for repeated move string on even line
  78.     add    di,bp    ;calc address of next line DI + (2000h-width)
  79.     mov    cx,ax    ;put width of image in bytes in CX to prepare
  80.     rep    movsb    ; for repeated move string on odd line
  81.     sub    di,dx    ;calc address of next line DI - (1fb0h+width)
  82.     endm
  83.     ret
  84. ;
  85. ;This table is used as an indirect address for jumping into
  86. ; the inline code for image moving.
  87. ;
  88. inline_height_vector_table label word ;there is no entry point for zero
  89.                       ; lines. Starting at 2 eliminates
  90.                       ; the need to store a dummy entry
  91.                     ; point address
  92. entry_address    macro    x        ;this macro is used to generate
  93.         dw    line&x&     ; the labels corresponding to
  94.         endm            ; the inline code entry points
  95. ;
  96. x=2
  97.     rept    20
  98.     entry_address    %x
  99. x=x+2
  100.     endm
  101. ;
  102. byte_move_form_driver endp
  103. ;
  104. cseg    ends
  105.     end
  106.